<?php
	if($id == FALSE){
		$nama_ijin	= set_value("nama_ijin");
		$keterangan	= set_value("keterangan");
		$status		= set_value("status");
	} else {
		$nama_ijin	=(set_value("nama_ijin") == "") ? ($value["NAMA_IJIN"]) : (set_value("nama_ijin"));
		$keterangan	=(set_value("keterangan") == "") ? ($value["KETERANGAN"]) : (set_value("keterangan"));
		$status	=(set_value("status") == "") ? ($value["STATUS"]) : (set_value("status"));
	}
?>

<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h4>
					<span>Form Master Ijin</span>
				</h4>
			</div>
			<div class="panel-body">
				<form class="form-horizontal" action="" method="post" id="form-validate" role="form">
					<div class="form-group hidden">
						<label class="col-lg-3 control-label" for="normalInput">ID Nama Ijin</label>
						<div class="col-lg-3">
							<input type="text" name="id" value="<?php echo $id; ?>" class="form-control">
						</div>
					</div><!-- End .form-group  -->
					<div class="form-group">
						<label class="col-lg-3 control-label" for="normalInput">Nama Ijin</label>
						<div class="col-lg-3">
							<input type="text" name="nama_ijin" value="<?php echo $nama_ijin; ?>" class="form-control">
						</div>
					</div><!-- End .form-group  -->
					<div class="form-group">
						<label class="col-lg-3 control-label" for="textareas">Keterangan</label>
						<div class="col-lg-3">
							<textarea id="textarea1" rows="3" name="keterangan" class="form-control elastic"><?php echo $keterangan; ?></textarea>
						</div>
					</div><!-- End .form-group  -->
					<?php if($id==FALSE) { ?>
						<div class="form-group">
							<label class="col-lg-3 control-label" for="select">Status</label>
							<div class="col-lg-3">
								<select name="status" class="form-control">
									<option value="">--Pilih Status--</option>
									<option <?php echo ($status == null) ? ("") : (($status == 1) ? ("selected") : ("")); ?> value="1" selected>Aktif</option>
									<option <?php echo ($status == null) ? ("") : (($status == 0) ? ("selected") : ("")); ?> value="0">Tidak Aktif</option>
								</select>
							</div>
						</div><!-- End .form-group  -->
					<?php } else { ?>
						<div class="form-group">
							<label class="col-lg-3 control-label" for="select">Status</label>
							<div class="col-lg-3">
								<select name="status" class="form-control">
									<option value="">--Pilih Status--</option>
									<option <?php echo ($status == null) ? ("") : (($status == 1) ? ("selected") : ("")); ?> value="1">Aktif</option>
									<option <?php echo ($status == null) ? ("") : (($status == 0) ? ("selected") : ("")); ?> value="0">Tidak Aktif</option>
								</select>
							</div>
						</div><!-- End .form-group  -->
					<?php } ?>
					<div class="form-group">
						<div class="col-lg-offset-3 col-lg-9">
							<button type="submit" class="btn btn-info">Simpan</button>
							<button type="reset" class="btn btn-warning">Reset</button>
							<button type="button" onClick="kembali()" class="btn btn-default">Kembali</button>
						</div>
					</div><!-- End .form-group  -->

				</form>

			</div>
		</div>
	</div>

</div><!-- End .panel -->

<script language="javascript">
function kembali(){
	document.location="<?php echo site_url("master_ijin"); ?>";
}

$(document).ready(function() {
    $("#form-validate").validate({
    	ignore: null,
    	ignore: 'input[type="hidden"]',
    	rules: {
			nama_ijin: "required",
			status:{
				required: true
			}
		},
		messages: {
			nama_ijin: "Baris ini wajib diisi !!!",
			status: "Pilih salah satu opsi !!!"
		}
    });
});
</script>